/**
 * Orienteering Sport Diary Copyright (C) 2009 OSDiary Team
 *
 * This file is part of Orienteering Sport Diary (OSDiary).
 *
 * OSDiary is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see http://www.gnu.org/licenses/.
 */

package org.actions.race;

import com.opensymphony.xwork2.ActionSupport;   
import java.sql.Time;
import org.data.ORace;
import org.util.EventDAO;

/**
 *
 * @author George.Mavchun
 */
public class SaveORaceAction extends ActionSupport {
    private String eventId;
    private String duration;
    private String distance;
    private String average_pulse;
    private String max_pulse;        
    private String min_pulse;
    private String climb;
    private String controls_count;
    private String map_link;            
    private String description;
    
    @Override
    public String execute() {
        
        ORace or = new ORace();
        or.duration = Time.valueOf(duration);
        or.distance = Integer.parseInt(distance);
        or.average_pulse = Integer.parseInt(average_pulse);
        or.max_pulse = Integer.parseInt(max_pulse);
        or.min_pulse = Integer.parseInt(min_pulse);
        or.climb = Integer.parseInt(climb);
        or.description = description;
        or.controls_count = Integer.parseInt(controls_count);
        or.map_link = map_link;

        EventDAO.addORace(Integer.parseInt(eventId), or);
        
        return SUCCESS;
    }

    public void setAverage_pulse(String average_pulse) {
        this.average_pulse = average_pulse;
    }

    public void setClimb(String climb) {
        this.climb = climb;
    }

    public void setDistance(String distance) {
        this.distance = distance;
    }

    public void setDuration(String duration) {
        this.duration = duration;
    }

    public void setEventId(String eventId) {
        this.eventId = eventId;
    }

    public void setMax_pulse(String max_pulse) {
        this.max_pulse = max_pulse;
    }

    public void setMin_pulse(String min_pulse) {
        this.min_pulse = min_pulse;
    }
    
    public void setControls_count(String controls_count) {
        this.controls_count = controls_count;
    }

    public void setMap_link(String map_link) {
        this.map_link = map_link;
    }
   
    public void setDescription(String description) {
        this.description = description;
    }
}
